package com.mapper;

import com.pojo.KeCheng_db;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface KeChengMapper_db {

    List<KeCheng_db> list(@Param("name") String name,@Param("del") Integer del);

    List<KeCheng_db> listAll(@Param("order") Integer order,@Param("limit") Integer limit);

    KeCheng_db findById(Integer id);

    @Select("select * from kecheng_db where k_tid = #{tId}")
    List<KeCheng_db> listById(Integer tId);

    @Select("select * from kecheng_db where k_hot = 1 and k_del != 0")
    List<KeCheng_db> listHot();

    @Insert("insert into kecheng_db(k_title,k_jianjie,k_price,k_oldprice,k_tupian,k_shipin,k_tid,k_time,k_xuexi,k_shoucang,k_del,k_hot) values (#{kTitle},#{kJianjie},#{kPrice},#{kOldprice},#{kTupian},#{kShipin},#{kTid},#{kTime},#{kXuexi},#{kShoucang},#{kDel},#{kHot})")
    @Options(useGeneratedKeys = true,keyProperty = "kId")
    Integer add(KeCheng_db keChengDb);

    @Update("update kecheng_db set k_title = #{kTitle},k_jianjie = #{kJianjie},k_price = #{kPrice},k_oldprice = #{kOldprice},k_tupian = #{kTupian},k_shipin = #{kShipin},k_tid = #{kTid},k_time = #{kTime},k_xuexi = #{kXuexi},k_shoucang = #{kShoucang},k_del = #{kDel},k_hot = #{kHot} where k_id = #{kId}")
    Integer update(KeCheng_db keChengDb);

    @Update("update kecheng_db set k_del = #{del} where k_id = #{id}")
    Integer updateDel(@Param("del") Integer kDel,@Param("id") Integer kId);

    @Update("update kecheng_db set k_hot = #{hot} where k_id = #{id}")
    Integer updateHot(@Param("hot") Integer kHot,@Param("id") Integer kId);

    @Delete("delete from kecheng_db where k_id = #{kId}")
    Integer del(Integer kId);
}
